package com.qf.yuandanwork.utils;

import cn.hutool.core.util.RandomUtil;
import com.alibaba.druid.sql.visitor.functions.If;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {
   private static String string=null;
    public static String birthday() throws IOException {



            int year= RandomUtil.randomInt(1970, 2023);
            int mon=RandomUtil.randomInt(1, 13);
            int day=0;
            if (year%4==0&&mon==2){
                //闰年 2月29天
                day=RandomUtil.randomInt(1, 30);
            }else if (year%4!=0&&mon==2){
                //平年 2月28天
                day=RandomUtil.randomInt(1, 29);
            }else{
                //正常按照30天算
                day=RandomUtil.randomInt(1, 31);
            }
           string=year+"-"+mon+"-"+day;



        return string;
    }
    public static Date utils(String string){
        SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd");
        Date date=null;
        try {
            date=dateFormat.parse(string);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }
    public static String registTime() throws IOException {
        //将文件中的数据以-分割
        String[] split = string.split("-");
        int i = Integer.parseInt(split[0]);
        int i1=i+18;
        String s1=i1+"-"+split[1]+"-"+split[2];

return s1;
    }







}
